<%-- 
    Document   : index
    Created on : Jul 9, 2011, 10:23:26 AM
    Author     : DangDucThinh
    UpdateDate: 2011/07//27
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="ProjectMgtSystem.Entities.Task" %>
<%@page import="ProjectMgtSystem.Entities.Engineer" %>
<%@taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@taglib  uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta http-equiv="Content-Style-Type" content="text/css" />
        <link href="css/style1.css" rel="stylesheet" type="text/css" />
        <link href="css/layout.css" rel="stylesheet" type="text/css" />
        <script type ="text/javascript" src="js/jquery-1.5.1.min.js"></script>
        <script type="text/javascript">
            $(document).ready(function(){
                $(".insBtt").click(function(){
                    $(".insert").toggle();
                });
            });
        </script>

        <script type="text/javascript">
            function show_confirm()
            {
                if(confirm("Are your sure?")){
                    //                                         window.location("engineer.do?method=Delete");
                }
                else
                    return false;
            }
        </script>
        <script type="text/javascript">
            function show_error(val)
            {    
                var msgErr = val;
                if(msgErr != "" && msgErr!="1"){
                    if(msgErr != "-1") {
                        alert(msgErr);
                    }
                    else{
                        alert("Data error!!!")
                    }
                    $(".insert").toggle(true);
            <% request.setAttribute("errorMessage", "");%>
                    }                                    
                    else
                        return false;
                }
        </script>
        <script>
            $(document).ready(function(){
                show_error("<%= request.getAttribute("errorMessage").toString()%>");                 
            });
        </script>
        <script type="text/javascript">
            function validateForm()
            {
                var x=document.forms["enfrm"]["txtEngineerID"].value
                if (x==null || x=="")
                {
                    alert("First name must be filled out");
                    return false;
                }
            }
        </script>
    </head>

    <body id="page1">
        <!-- header -->
        <div class="inner_copy"></div> 
        <div id="header">
            <div class="container">
                <!-- .logo -->
                <div class="logo">
                    <a href="index.html"><img src="images/logo1.jpg" alt="" /></a>
                </div>
                <!-- /.logo -->
                <!-- .nav -->
                <ul class="nav">
                    <li><a href="AdminHomepage.jsp">HOME</a></li>
                    <li><html:link href="engineer.do?method=View">ENGINEER</html:link></li>
                    <li><a href="#" class="current">PROJECT</a></li>
                    <li><html:link href="TaskAction.do?method=View">TASK</html:link></li> 
                </ul>
                <!-- /.nav -->
                <form action="" id="search-form">
                    <fieldset>
                        <p>Back to <a href="login.jsp">log in</a> page.</p>
                    </fieldset>
                </form>

            </div>
        </div>
        <!-- content -->
        <div id="content">
            <div class="container">
                <div class="inside">
                    <div class="wrapper">
                        <!--left category-->
                        <!--end left category -->
                        <div class="mainContent">

                            <!------------------------------------------------------------------------------------------------------->                            
                            <!----------------------------- Our main content begins here -------------------------------------------->


                            <table>
                                <tr>
                                    <th>Project ID</th>
                                    <td><bean:write name="ProjectActionBean" property="projectID" /></td>
                                </tr>
                            </table>
                            <br/>
                            <br/>
                            <h1>Tasks that assigned to project <bean:write name="ProjectActionBean" property="projectID" />.</h1>
                            <br/>
                            <table id="mytable" cellspacing="0">
                                <tr>
                                    <th scope="col">Task ID</th>
                                    <th scope="col">Task Name</th>
                                </tr>
                                <%
                                    java.util.ArrayList<Task> assignedTaskList = (java.util.ArrayList<Task>) request.getAttribute("assignedTaskList");
                                    for (Task task : assignedTaskList) {%>
                                <html:form action="/ProjectAction">
                                    <tr>
                                        <%
                                            out.print("<td>" + task.getTaskID() + "</td>");
                                            out.print("<td>" + task.getTaskName() + "</td>");
                                        %>
                                        <html:hidden property="taskID" value="<%=task.getTaskID()%>"/>
                                        <td><html:submit property="method" onclick="return show_confirm()"><bean:message key="ProjectAction.deleteTasks"/></html:submit></td>
                                    </tr>
                                </html:form>   
                                <%
                                    }
                                %>
                            </table>

                            <br/>
                            <br/>
                            <br/>
                            <br/>
                            <br/>
                            <br/>

                            <div class="add"><button class="insBtt">Assign New Tasks To This Project</button></div>
                            <div class="insert">
                                <html:form action="/ProjectAction">
                                    <table id="mytable" cellspacing="0">
                                        <tr>
                                            <th scope="col"></th>
                                            <th scope="col">Task ID</th>
                                            <th scope="col">Task Name</th>
                                        </tr>
                                        <%
                                            java.util.ArrayList<Task> notAssignedTaskList = (java.util.ArrayList<Task>) request.getAttribute("notAssignedTaskList");
                                            for (Task task : notAssignedTaskList) {
                                        %>
                                        <tr>
                                            <td>
                                                <html:multibox property="selectedItems" value="<%=task.getTaskID()%>"></html:multibox>
                                            </td>
                                            <%
                                                out.print("<td>" + task.getTaskID() + "</td>");
                                                out.print("<td>" + task.getTaskName() + "</td>");
                                            %>
                                        </tr>   

                                        <%
                                            }
                                        %>
                                    </table>
                                    <html:submit property="method"><bean:message key="ProjectAction.assignTasks"/></html:submit>
                                </html:form> 
                            </div>
                            <!-----------------------------End main content-------------------------------------------------------------->

                        </div>
                    </div>
                            <div style="text-align: right"><html:link href="ProjectAction.do?method=View">Back to Project Page</html:link></div>
                </div>
            </div>
        </div>
        <!-- footer -->
        <div id="footer">
            <div class="container">
                <div class="inside">
      	Copyright &copy; Team A POSCO-ICT
                </div>
            </div>
        </div>
    </body>
</html>
